package com.docmgmt.mvp.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 操作日志表
 * </p>
 *
 * @author Dora
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("sys_operation_log")
public class OperationLogEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 日志ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 操作人ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 用户名（冗余）
     */
    @TableField("username")
    private String username;

    /**
     * 操作类型：upload/download/delete/share/permission等
     */
    @TableField("operation")
    private String operation;

    /**
     * 资源类型（v3.0新增）：file/folder/user/dept等
     */
    @TableField("resource_type")
    private String resourceType;

    /**
     * 资源ID（v3.0新增）
     */
    @TableField("resource_id")
    private Long resourceId;

    /**
     * 资源名称（v3.0新增）
     */
    @TableField("resource_name")
    private String resourceName;

    /**
     * IP地址
     */
    @TableField("ip_address")
    private String ipAddress;

    /**
     * User-Agent
     */
    @TableField("user_agent")
    private String userAgent;

    /**
     * 状态：success/failed
     */
    @TableField("status")
    private String status;

    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
}
